<template>
  <view>
    <addressList :shipadd-id="shipaddId" :address-list="addressList" :type="type" />
  </view>
</template>

<script>
import addressList from '@/components/address-list'
import { getAddressList } from '@/api/address';
export default {
  components: {
    addressList,
  },
  data() {
    return {
      title: 'Index',
      shipaddId: '', //选中的地址
      addressList: [],
      pageNum: 1,
      type: ''
    }
  },
  onShow() {
    this.pageNum = 1
    this.addressList = []
    this.getAddressList()
  },
  onLoad(option) {
    console.log('页面传值', option)
    this.type = option.type
    this.shipaddId = option.id
  },
  onReachBottom() {
    this.pageNum += 1
    this.getAddressList();
  },
  methods: {
    statusClick(item) {
      if (this.current == 0) {
        this.pageNum = 1
        this.addressList = []
        this.$nextTick(() => {
          this.getAddressList(1);
        })
      } else {
        setTimeout(() => {
          this.$refs['region'].getAddressList();
        }, 1000)
      }
    },
    getParams() {
      uni.navigateBack(-1)
    },
    async getAddressList() {
      const { customerId, memberId } = this.vuex_memberInfo
      const params = {
        pageNum: this.pageNum,
        pageSize: 10,
        member_id: memberId,
        type: 10, // 10默认，20代客下单
        customer_id: customerId
      }
      const res = await getAddressList(params)
      if (res.errorCode == 0) {
        this.addressList = [...this.addressList, ...res.list]
      }
    },
  }
}
</script>

<style lang="scss">

</style>
